/*
 * ResearchGrantsApp.java
 */

package researchgrants;

import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel;
import java.awt.Color;
import java.awt.Font;
import java.awt.Insets;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
import org.jdesktop.application.Application;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.SingleFrameApplication;

/**
 * The main class of the application. Loads and displays the main <code>FrameView</code> of the application: <code>ResearchGrantsView</code>.
 */
public class ResearchGrantsApp extends SingleFrameApplication {

    /**
     * A reference to the only frame view.
     */
    static private FrameView mainFrameView=null;
    
    /** 
     * A getter for the main frame view.
     * @return the instance of the main frame view
     */
    public static FrameView getMainFrameView() {
        return(mainFrameView);
    }
    
    /**
     * creates and shows the main frame of the application at startup.
     * <p>
     * Resets the lookAndFeel to requirements.
     */
    @Override protected void startup() {
        try {
            NimbusLookAndFeel lookAndFeel=new NimbusLookAndFeel();
            UIManager.setLookAndFeel(lookAndFeel);
            UIDefaults defaults=UIManager.getLookAndFeelDefaults();
            defaults.put("background", new ColorUIResource(new Color(236, 233, 216)));
            FontUIResource fontUiResource=new FontUIResource(Font.DIALOG, Font.PLAIN, 12);
            defaults.put("font", fontUiResource);
            defaults.put("Button.font", fontUiResource);
            defaults.put("RadioButton.font", fontUiResource);
            defaults.put("ToggleButton.font", fontUiResource);
            defaults.put("CheckBox.font", fontUiResource);
            defaults.put("ColorChooser.font", fontUiResource);
            defaults.put("ComboBox.font", fontUiResource);
            defaults.put("FileChooser.font", fontUiResource);
            defaults.put("FileView.font", fontUiResource);
            defaults.put("InternalFrame.font", fontUiResource);
            defaults.put("Label.font", fontUiResource);
            defaults.put("List.font", fontUiResource);
            defaults.put("MenuBar.font", fontUiResource);
            defaults.put("MenuItem.font", fontUiResource);
            defaults.put("RadioButtonMenuItem.font", fontUiResource);
            defaults.put("CheckBoxMenuItem.font", fontUiResource);
            defaults.put("Menu.font", fontUiResource);
            defaults.put("PopupMenu.font", fontUiResource);
            defaults.put("OptionPane.font", fontUiResource);
            defaults.put("Panel.font", fontUiResource);
            defaults.put("ProgressBar.font", fontUiResource);
            defaults.put("ScrollPane.font", fontUiResource);
            defaults.put("Viewport.font", fontUiResource);
            defaults.put("TabbedPane.font", fontUiResource);
            defaults.put("Table.font", fontUiResource);
            defaults.put("TableHeader.font", fontUiResource);
            defaults.put("TextField.font", fontUiResource);
            defaults.put("PasswordField.font", fontUiResource);
            defaults.put("TextArea.font", fontUiResource);
            defaults.put("TextPane.font", fontUiResource);
            defaults.put("EditorPane.font", fontUiResource);
            defaults.put("TitledBorder.font", fontUiResource);
            defaults.put("ToolBar.font", fontUiResource);
            defaults.put("ToolTip.font", fontUiResource);
            defaults.put("Tree.font", fontUiResource);
            
            
            defaults.put("Button.contentMargins", new Insets(4, 5, 4, 5));
//            BorderUIResource borderResource=(BorderUIResource) defaults.get("Button.border");
//            Border loweredBevelBorderUIResource = BorderUIResource.getLoweredBevelBorderUIResource();
//            loweredBevelBorderUIResource=new BevelBorder(isRaised, darkShadow, lightShadow)
//            BorderUIResource borderResource=new BorderUIResource(new EmptyBorder(100, 100, 100, 100));
//            ButtonUI buttonUi=new ButtonUI() {};
//            buttonUi.
//            defaults.put("ButtonUI", );

//            WindowsLookAndFeel lookAndFeel=new WindowsLookAndFeel();
//            UIManager.setLookAndFeel(lookAndFeel);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(ResearchGrantsApp.class.getName()).log(Level.SEVERE, null, ex);
        }
        mainFrameView=new ResearchGrantsView(this);
        show(mainFrameView);
        
    }

    /**
     * This method is to initialize the specified window by injecting resources.
     * Windows shown in our application come fully initialized from the GUI
     * builder, so this additional configuration is not needed.
     */
    @Override protected void configureWindow(java.awt.Window root) {
    }

    /**
     * A convenient static getter for the application instance.
     * @return the instance of ResearchGrantsApp
     */
    public static ResearchGrantsApp getApplication() {
        return Application.getInstance(ResearchGrantsApp.class);
    }

    /**
     * Main method launching the application.
     */
    public static void main(String[] args) {
        launch(ResearchGrantsApp.class, args);
    }
}
